{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "af165506-cc16-485c-8875-f1ec55dd94b5",
   "metadata": {},
   "outputs": [],
   "source": [
    "!pip install burr[start]"
   ]
  },
  {
   "cell_type": "code",
   "id": "5cc77bd80999b2a2",
   "metadata": {
    "collapsed": false,
    "jupyter": {
     "outputs_hidden": false
    },
    "ExecuteTime": {
     "end_time": "2024-08-31T04:30:47.929817Z",
     "start_time": "2024-08-31T04:30:46.259173Z"
    }
   },
   "source": [
    "%%sh \n",
    "burr-test-case create --help"
   ],
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Usage: burr-test-case create [OPTIONS]\n",
      "\n",
      "  Create a test case from a persisted state.\n",
      "\n",
      "  Does two things:\n",
      "\n",
      "  1. Pulls data specified and saves it/prints to console. 2. Prints a pytest\n",
      "  test case to the console for you to cut and paste.\n",
      "\n",
      "  See examples/test-case-creation/notebook.ipynb for example usage. See\n",
      "  examples/test-case-creation/test_application.py for details.\n",
      "\n",
      "  If you have custom serialization/deserialization then pass in the name of a\n",
      "  python module, or a path to a python file, to import with your custom\n",
      "  serialization/deserialization registration functions. This will be imported\n",
      "  so that they can be registered.\n",
      "\n",
      "  Note:     - when burr fails, then the state retrieved for a sequence ID is\n",
      "  the state at the start of the sequence ID.       The fixture created will\n",
      "  only have input state.     - when burr completes successfully, then the\n",
      "  state retrieved for a sequence ID is the final modified state.       The\n",
      "  fixture created will have input and output state, as we will grab the prior\n",
      "  sequence ID's state       as the input state.     - we strip any keys\n",
      "  prefixed with __ from the state to avoid exposing private keys in the test\n",
      "  case.\n",
      "\n",
      "Options:\n",
      "  --project-name TEXT      Name of the project.  [required]\n",
      "  --partition-key TEXT     Partition key to look at.\n",
      "  --app-id TEXT            App ID to pull from.  [required]\n",
      "  --sequence-id TEXT       Sequence ID to pull.  [required]\n",
      "  --target-file-name TEXT  What file to write the data to. Else print to\n",
      "                           console.\n",
      "  --serde-module TEXT      Python file or fully qualified python module to\n",
      "                           import for custom serialization/deserialization.\n",
      "  --action-name TEXT       Provide name of the action for the test case.\n",
      "                           Defaults to the action name at the sequence ID.\n",
      "  --help                   Show this message and exit.\n"
     ]
    }
   ],
   "execution_count": 1
  },
  {
   "cell_type": "markdown",
   "id": "944a988132d19779",
   "metadata": {
    "collapsed": false,
    "jupyter": {
     "outputs_hidden": false
    }
   },
   "source": [
    "# Create a test case\n",
    "\n",
    "Find the data you want to create a test case with in the UI."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "id": "586bcb0bdb5dde8b",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2024-04-01T06:16:19.392833Z",
     "start_time": "2024-04-01T06:16:18.000721Z"
    },
    "collapsed": false,
    "jupyter": {
     "outputs_hidden": false
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Found data for action:  plan_cot\n",
      "\n",
      "Writing data to file /tmp/test-case.json\n",
      "\n",
      "Add the following to your test file:\n",
      "\n",
      "import pytest\n",
      "from burr.testing import pytest_generate_tests  # noqa: F401\n",
      "# TODO: import action you're testing, i.e. import plan_cot.\n",
      "\n",
      "@pytest.mark.file_name(\"/tmp/test-case.json\")\n",
      "def test_plan_cot(input_state, expected_state):\n",
      "    \"\"\"Function for testing the action\"\"\"\n",
      "    input_state = state.State(input_state)\n",
      "    expected_state = state.State(expected_state)\n",
      "    _, output_state = plan_cot(input_state)  # exercise the action\n",
      "    assert output_state == expected_state\n",
      "\n"
     ]
    }
   ],
   "source": [
    "%%sh\n",
    "burr-test-case create \\\n",
    "     --project-name \"SOME_PROJECT\" \n",
    "     --partition-key \"SOME_KEY\" \\\n",
    "     --app-id \"SOME_ID\" \\\n",
    "     --sequence-id 0 \\\n",
    "     --target-file-name /tmp/test-case.json"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "3ac9d600d0807fc8",
   "metadata": {
    "collapsed": false,
    "jupyter": {
     "outputs_hidden": false
    }
   },
   "source": [
    "# What's next?\n",
    " \n",
    "## See `test_application.py` for code that enables you to run the test case like this.\n",
    "\n",
    "## Fill in the expected state part of the JSON\n",
    "The expected state part of the JSON is empty. You need to fill it in with the expected state of the application after the test case has been run. Once you've\n",
    "done that, you've got your test case!\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "a727cdc01303cd39",
   "metadata": {
    "collapsed": false,
    "jupyter": {
     "outputs_hidden": false
    }
   },
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.10.4"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
